<!--@
/*
 * For update translations:
 * $> scriptreporttool -c music.srt
 * $> lupdate music.srt.js -ts music_es.ts
 * $> rm music.srt.js
 * $> cp music.srt music.srt.js
 * Update translations
 * $> lrelease music_es.ts
 */
sr.report.paper.margins.setMargins(1.5,2,1.5,2,"cm");

sr.engine.importExtension("sri18n");
sr.i18n.installTranslator("music_es.qs");
sr.i18n.installTranslatorFunctions();

sr.engine.importExtension("srsql");
var db;
if (sr.report.isEditing) {
    db = sr.sql.addDatabase("QSQLITE", "music");
    db.databaseName = "music.db";
    db.open();
} else {
    db = sr.sql.database("music");
}
/*
 * Test
 * something else
 */
if(sr.report.isDebbuging) {
    print(db.tables("AllTables"));
    var record = db.record("songs");
    for (var i = 0; i < record.count; i++) {
        print(record.fieldName(i));
    }
}
-->

<!--:headerFirst-->

<!--:header-->
<center><b>${qsTr("Music Report")}</b></center>

<!--:footer-->
<center>${sr.report.page}/${sr.report.pageCount}</center>

<!--:content-->

<!--@
var query = db.query("SELECT * FROM songs order by artist, title");
-->

<h1><center><img src="?{":/"}book.png">&nbsp;${qsTr("Music Report")}</center></h1>
<br>
<!--@
var artist = query.record().indexOf("artist");
var title = query.record().indexOf("title");
var length = query.record().indexOf("length");
var year = query.record().indexOf("year");
-->
<table width="100%" cellspacing="-1" cellpadding="2" border="1" style="border-style:solid;border-color:black;" >
    <thead>
        <tr>
            <td><b>${qsTr("Artist")}</b></td>
            <td><b>${qsTr("Title")}</b></td>
            <td><b>${qsTr("Lenght")}</b></td>
            <td><b>${qsTr("Year")}</b></td>
        </tr>
    </thead>
    <tbody>
    <!--@
    for (var n=0; n < 10; n++) {
        while (query.next()) {
    -->
            <tr>
                <td>${query.value(artist)}</td>
                <td>${query.value(title)}</td>
                <td>${query.value(length)}</td>
                <td>${query.value(year)}</td>
            </tr>
    <!--@
        }
        query.first();
    }
    -->
    </tbody>
</table>



<!--@
if (sr.report.isDebbuging) {
    print("end");
}
-->
